<script setup lang="ts">
import { onMounted } from "vue";
import { useRouter } from "vue-router";
import BackToTop from '~/components/base/BackToTop.vue';

onMounted(() => {
  // 处理页面刷新时的滚动
  window.scrollTo({
    top: 0,
    behavior: "auto",
  });
});

// 处理路由切换时的滚动
const router = useRouter();

router.beforeEach((to, from) => {
  window.scrollTo({
    top: 0,
    behavior: "auto",
  });
  return true;
});
</script>

<template>
  <NuxtLayout>
    <NuxtPage />
    <BackToTop />
  </NuxtLayout>
</template>
